home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 August / August CD.bin / Shareware / Education / numericalmethods Folder / chap_11 / a11_5.m < prev    next >
Encoding:
Text File  |  1994-06-05  |  1.8 KB  |  64 lines  |  [MATS/MATL]

  1. echo off;
  2. % NUMERICAL METHODS: MATLAB Programs, (c) John H. Mathews 1994
  3. % To accompany the text:
  4. % NUMERICAL METHODS for Mathematics, Science and Engineering, 2nd Ed, 1992
  5. % Prentice Hall, Englewood Cliffs, New Jersey, 07632, U.S.A.
  6. % This free software is complements of the author.
  7.  
  8. % Algorithm 11.5 (The QL Method with Shifts).
  9. % Section    11.4,    Eigenvalues of Symmetric Matrices, Page 587
  10. echo on; clc; format long; hold off; clear
  11.  
  12. %            THE QL ALGORITHM
  13.  
  14. %     Assume that A  = A is real, symmetric and tridiagonal.
  15. %                  1
  16. % The QL method constructs orthogonal matrices {Q } so that
  17. %                                                k
  18. %     A  = Q L  where L  is lower-triangular, and
  19. %      k    k k        k
  20.  
  21. %     A     =  Q  A  Q    for k = 1,2, ... .
  22. %      k+1      k  k  k
  23.  
  24. % Then    lim  A  = D,   where D is a diagonal matrix 
  25. %        k->oo  k
  26.  
  27. % with the same eigenvalues as the original matrix A.
  28.  
  29. % Remark. ql.m is used for Algorithm 11.5
  30.  
  31. pause % Press any key to continue.
  32.  
  33. clc;
  34. %      We will now proceed with the QL method of iteration
  35.  
  36. % to reduce the tridiagonal matrix  A  to diagonal form.
  37.  
  38. % A  must be symmetric and tridiagonal.
  39.  
  40. % Place the matrix in  A.
  41.  
  42. % Place the tolerance in  epsilon
  43.  
  44. A = [ 4  -3                  0                  0;
  45.      -3   2                  3.16227766016838   0;
  46.       0   3.16227766016838  -1.4               -0.2;
  47.       0   0                 -0.2                1.4];
  48.  
  49. epsilon = 1e-10;
  50.  
  51. D = ql(A,epsilon,1);
  52.  
  53. pause % Press any key to continue.
  54.  
  55. clc;
  56. Mx1 = 'Implementation of the QL method with shifts.';
  57. Mx2 = 'The matrix  A  is:';
  58. Mx3 = 'The similar diagonal matrix is:'
  59. Mx4 = 'The eigenvalues are:';
  60. clc,echo off,diary output,...
  61. disp(' '),disp(Mx1),disp(' '),disp(Mx2),disp(A),disp(Mx3),...
  62. disp(diag(D)),disp(Mx4),disp(D),...
  63. diary off,echo on
  64.